
import { areaList } from '@vant/area-data'
import dayjs from 'dayjs'

// 当前日期
const startDate = dayjs().format('YYYY-MM-DD')

// 后推6个月日期
const endDate = dayjs().add(7, 'month').format('YYYY-MM-DD')


/**
 * 函数类型，函数事例
 * _this的属性更改可以双向绑定
 * 函数的三个变量_this、item、parentData：
    1、_this:当前对象实例
    2、item:当前联动的数据，
    3、parentData:上级字段的所有数据
 * 
 * (function test() {
  // console.log(_this, item, parentData)
  // 设置option
  _this.optionList = ['123456', '===']
})()
 */
/**
 * 联动校验格式
 * InputInput类型,"当前选项"比较 类型，"上级字段"也是比较类型
 * {
  "parentId": "1665457921302", 
  "linkageData": {
      "currentShow": "showAnd", 
      "parentParam": {
          "type": "2", 
          "reg": "", 
          "fnData": "", 
          "compareList": [
              {
                  "compare": "=", 
                  "compareValue": "2"
              }
          ]
      }, 
      "currentParam": {
          "type": "2", 
          "reg": "", 
          "fnData": "", 
          "compareList": [
              {
                  "compare": "<", 
                  "compareValue": "4"
              }
          ]
      }
  }
}
 */



export const panelList = [
  {
    "title": "输入型组件",
    "list": [
      {
        type: 'input',
        "label": "单行文本",
        "tag": "van-field",
        "tagIcon": 'input',
        "vModel": "",
        "placeholder": "请输入",
        "clearable": true,
        "maxlength": null,
        "isShow": true,
        "readonly": false,
        "disabled": false,
        "required": true,
        // 是否能手动修改默认值
        "manualDefaults": true,
        "regList": [
          {
            "reg": "/^[0-9]*$/",
            "msg": "只能输入数字"
          }
        ],
        "fnList": [],
        linkageList: []
      },
      {
        type: 'input',
        "label": "多行文本",
        "tag": "van-field",
        "tagIcon": "textarea",
        "vModel": "",
        "textType": "textarea",
        "placeholder": "请输入",
        "maxlength": null,
        "isShow": true,
        "readonly": false,
        "disabled": false,
        "required": true,
        // 是否能手动修改默认值
        "manualDefaults": true,
        "regList": [],
        "fnList": [],
        linkageList: []
      }
    ]
  },
  {
    "title": "选择型组件",
    "list": [
      {
        type: 'select',
        "label": "下拉选择",
        "tag": "van-pick",
        "tagIcon": 'select',
        "vModel": "",
        "placeholder": "请选择",
        "clearable": true,
        "disabled": false,
        "required": true,
        "multiple": false,
        "isShow": true,
        "readonly": false,
        // 是否能手动修改默认值
        "manualDefaults": false,
        optionsSource: '0',
        urlData: {
          urlOptions: [],
          urlSource: ''
        },
        "options": [
          {
            "label": "选项一",
            "value": '1'
          },
          {
            "label": "选项二",
            "value": '2'
          }
        ],
        "dataList": {},
        "regList": [],
        "fnList": [],
        linkageList: []
      },
      {
        type: 'area',
        "label": "地区级联",
        "tag": "van-area",
        "tagIcon": 'cascader',
        "vModel": "",
        "placeholder": "请选择",
        "isShow": true,
        "readonly": false,
        "disabled": false,
        "clearable": true,
        "required": true,
        "columns": 3,
        title: '标题',
        optionsSource: '0',
        urlData: {
          urlOptions: [],
          urlSource: ''
        },
        "areaList": areaList,
        // 是否能手动修改默认值
        "manualDefaults": false,
        "regList": [],
        "fnList": [],
        linkageList: []
      },
      {
        type: 'select',
        "label": "单选框组",
        "tag": "van-radio",
        "tagIcon": "radio",
        "vModel": "",
        "isShow": true,
        "readonly": false,
        "disabled": false,
        "required": true,
        // 是否能手动修改默认值
        "manualDefaults": false,
        optionsSource: '0',
        urlData: {
          urlOptions: [],
          urlSource: ''
        },
        "options": [
          {
            "label": "选项一",
            "value": '1'
          },
          {
            "label": "选项二",
            "value": '2'
          }
        ],
        "regList": [],
        "fnList": [],
        linkageList: []
      },
      {
        type: 'select',
        "label": "多选框组",
        "tag": "van-checkbox",
        "tagIcon": "checkbox",
        "vModel": '',
        "disabled": false,
        "isShow": true,
        "readonly": false,
        "required": true,
        // 是否能手动修改默认值
        "manualDefaults": false,
        optionsSource: '0',
        urlData: {
          urlOptions: [],
          urlSource: ''
        },
        "options": [
          {
            "label": "选项一",
            "value": '1'
          },
          {
            "label": "选项二",
            "value": '2'
          }
        ],
        "regList": [],
        "fnList": [],
        linkageList: []
      },
      {
        type: 'switch',
        "label": "开关",
        "tag": "van-switch",
        "tagIcon": "switch",
        "vModel": "false",
        "defaultValue": false,
        "style": {},
        "disabled": false,
        "isShow": true,
        "readonly": false,
        "required": true,
        "active-text": "",
        "inactive-text": "",
        "active-color": null,
        "inactive-color": null,
        "active-value": true,
        // 是否能手动修改默认值
        "manualDefaults": false,
        "regList": [],
        "fnList": [],
        linkageList: []
      },
      {
        type: 'slider',
        "label": "滑块",
        "tag": "van-slider",
        "tagIcon": "slider",
        "vModel": "",
        "defaultValue": null,
        "disabled": false,
        "isShow": true,
        "readonly": false,
        "required": true,
        "min": 0,
        "max": 100,
        "step": 1,
        "show-stops": false,
        "range": false,
        "regList": [],
        "fnList": [],
        linkageList: []
      },
      {
        type: 'time',
        "label": "时间选择",
        "tag": "van-datetime-picker",
        "tagIcon": "time",
        "vModel": "",
        "placeholder": "请选择",
        "disabled": false,
        "isShow": true,
        "readonly": false,
        "clearable": true,
        "required": true,
        // 是否能手动修改默认值
        "manualDefaults": false,
        title: '标题',
        datetimeType: 'time',
        "regList": [],
        "fnList": [],
        linkageList: []

        // {"parentId":"1665457921302","linkageData":{"currentShow":"showAnd","parentParam":{"type":"2","reg":"","fnData":"","compareList":[{"compare":"=","compareValue":"2"}]},"currentParam":{"type":"2","reg":"","fnData":"","compareList":[{"compare":"<","compareValue":"4"}]}}}
      },
      // {
      //   "label": "时间范围",
      //   "tag": "el-time-picker",
      //   "tagIcon": "time-range",
      //   "vModel": "",
      //   "defaultValue": null,
      //   "disabled": false,
      //   "isShow": true,
      //   "readonly": false,
      //   "clearable": true,
      //   "required": true,
      //   "is-range": true,
      //   "range-separator": "至",
      //   "start-placeholder": "开始时间",
      //   "end-placeholder": "结束时间",
      //   "format": "HH:mm:ss",
      //   "value-format": "HH:mm:ss",
      //   // 是否能手动修改默认值
      //   "manualDefaults": false,
      //   "regList": [],
      //   "fnList": []
      // },
      {
        type: 'time',
        "label": "日期选择",
        "tag": "van-calendar",
        "tagIcon": "date",
        "placeholder": "请选择",
        "vModel": "2022-10-10",
        "dateType": "single",
        "disabled": false,
        "isShow": true,
        "readonly": false,
        "clearable": true,
        "required": true,
        "format": "YYYY-MM-DD",
        style: {
          color: '#1989fa'
        },
        rangeDate: [startDate, endDate],
        position: 'bottom',
        maxRange: 1000,
        // 是否能手动修改默认值
        "manualDefaults": false,
        "regList": [],
        "fnList": [],
        linkageList: []
      },
      {
        type: 'time',
        "label": "日期范围",
        "tag": "van-calendar",
        "tagIcon": "date-range",
        "vModel": "2022-10-10至2022-11-10",
        "dateType": "range",
        "placeholder": "请选择",
        "disabled": false,
        "isShow": true,
        "readonly": false,
        "clearable": true,
        "required": true,
        "format": "YYYY-MM-DD",
        style: {
          color: '#1989fa'
        },
        rangeDate: [startDate, endDate],
        position: 'bottom',
        maxRange: 1000,
        // 是否能手动修改默认值
        "manualDefaults": false,
        "regList": [],
        "fnList": [],
        linkageList: []
      },
      {
        type: 'uploader',
        "label": "上传",
        "tag": "van-uploader",
        "tagIcon": "upload",
        "vModel": "",
        "action": "https://jsonplaceholder.typicode.com/posts/",
        "disabled": false,
        "isShow": true,
        "readonly": false,
        "required": true,
        "auto-upload": true,
        "showTip": false,
        "buttonText": "点击上传",
        "list-type": "text",
        "multiple": false,
        // 是否能手动修改默认值
        "manualDefaults": false,
        "regList": [],
        "fnList": [],
        linkageList: []
      }
    ]
  },
  {
    "title": "操作型组件",
    "list": [
      {
        type: 'operat',
        "label": "按钮",
        "tag": "van-button",
        "tagIcon": "upload",
        btnType: 'primary',
        plain: false,
        disabled: false,
        size: 'small',
        block: false,
        style: {
          color: ''
        },
      },
      {
        type: 'operat',
        "label": "标题",
        "tag": "title",
        "tagIcon": "upload",
        "style": {
          "fontSize": 18,
          "color": '#000',
          "paddingLeft": 15,
          "paddingRight": 5,
          "paddingTop": 5,
          "paddingBottom": 5,
          "background": "#fff",
          "fontWeight": 'bold'
        },
        operatShow: false,
        iconShow: true,
        textShow: true,
        textName: '按钮名称',
        iconName: 'icon-setting',
        operatStyle: {
          "textFontSize": 14,
          iconFontSize: 14,
          operatPaddingRight: 5
        }
      },
      {
        type: 'operat',
        "label": "间距",
        "tag": "space",
        "tagIcon": "upload",
        "style": {
          "height": '20',
        }
      },
      {
        type: 'operat',
        "label": "步骤",
        "tag": "van-steps",
        "tagIcon": "upload",
        active: "1",
        stepList: [
          { label: '第一步', value: "1" },
          { label: '第二步', value: "2" },
          { label: '第三步', value: "3" },
          { label: '第四步', value: "4" }
        ],
        style: {
          activecolor: '#38f'
        }
      }
    ]
  }
]



// 按需加载
export const componentMap = {
  'van-field': resolve => require(['./components/form/input'], resolve),
  'van-pick': (resolve) => require(['./components/form/pick'], resolve),
  'van-area': (resolve) => require(['./components/form/area'], resolve),
  'van-radio': (resolve) => require(['./components/form/radio'], resolve),
  'van-checkbox': (resolve) => require(['./components/form/checkbox'], resolve),
  'van-switch': (resolve) => require(['./components/form/switch'], resolve),
  'van-slider': (resolve) => require(['./components/form/slider'], resolve),
  'van-datetime-picker': (resolve) => require(['./components/form/datetime'], resolve),
  'van-calendar': (resolve) => require(['./components/form/calendar'], resolve),
  'van-uploader': (resolve) => require(['./components/form/uploader'], resolve),
  'van-steps': (resolve) => require(['./components/form/steps'], resolve),
  'title': (resolve) => require(['./components/form/title'], resolve),
  'space': (resolve) => require(['./components/form/space'], resolve),
  'van-button': (resolve) => require(['./components/form/button'], resolve),
}

// 私有配置按需加载
export const configMap = {
  'van-field': resolve => require(['./components/config/privateConfig/input'], resolve),
  'van-pick': (resolve) => require(['./components/config/privateConfig/pick'], resolve),
  'van-area': (resolve) => require(['./components/config/privateConfig/area'], resolve),
  'van-radio': (resolve) => require(['./components/config/privateConfig/radio'], resolve),
  'van-checkbox': (resolve) => require(['./components/config/privateConfig/checkbox'], resolve),
  'van-switch': (resolve) => require(['./components/config/privateConfig/switch'], resolve),
  'van-slider': (resolve) => require(['./components/config/privateConfig/slider'], resolve),
  'van-datetime-picker': (resolve) => require(['./components/config/privateConfig/datetime'], resolve),
  'van-calendar': (resolve) => require(['./components/config/privateConfig/calendar'], resolve),
  'van-uploader': (resolve) => require(['./components/config/privateConfig/uploader'], resolve),
  'van-steps': (resolve) => require(['./components/config/privateConfig/steps'], resolve),
  'title': (resolve) => require(['./components/config/privateConfig/title'], resolve),
  'space': (resolve) => require(['./components/config/privateConfig/space'], resolve),
  'van-button': (resolve) => require(['./components/config/privateConfig/button'], resolve),
}


export const timeOption = [
  { label: '年月日', value: 'date', format: 'YYYY-MM-DD' },
  { label: '时间', value: 'time', format: 'hh:mm' },
  { label: '年月', value: 'year-month', format: 'YYYY-MM' },
  { label: '月日', value: 'month-day', format: 'MM-DD' },
  { label: '年月日小时', value: 'datehour', format: 'YYYY-MM-DD hh:mm' },
]